package com.duanjw.bank;

import cn.hutool.json.JSONObject;
import com.duanjw.bank.rate.core.BankRate;
import com.duanjw.bank.rate.core.BankRateHandler;
import com.duanjw.bank.rate.core.BankInfoSyncNiceFlow;
import com.duanjw.bank.rate.handler.*;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * @author duanjw
 * @date 2024/4/1
 */
public class Main {
    public static void main(String[] args) throws IOException {
//        sendToNiceFlow();
        batchSendToNiceFlow();
    }

    public static void sendToNiceFlow() throws IOException {
        BankRateHandler bankRateHandler = new GongShangBanRateHandler();
        BankRate bankRate = bankRateHandler.getBankRate();
        System.out.println(bankRate);
        System.out.println(new JSONObject(bankRate).setDateFormat("yyyy-MM-dd"));
//        BankInfoSyncNiceFlow bankInfoSyncNiceFlow = new BankInfoSyncNiceFlow();
//        bankInfoSyncNiceFlow.sendToNiceFlow(bankInfoHandler.getBankName(), bankInfo);
    }
    public static void batchSendToNiceFlow() throws IOException {
        List<BankRateHandler> bankRateHandlers = getAll();
        BankInfoSyncNiceFlow bankInfoSyncNiceFlow = new BankInfoSyncNiceFlow();
        for (BankRateHandler bankRateHandler : bankRateHandlers) {
            bankInfoSyncNiceFlow.sendToNiceFlow(bankRateHandler.getBankName(), bankRateHandler.getBankRate());
        }
    }

    private static List<BankRateHandler> getAll() {
        List<BankRateHandler> bankRateHandlers = new ArrayList<>();
        bankRateHandlers.add(new BeiJingBanRateHandler());
        bankRateHandlers.add(new HuiShangBanRateHandler());
        bankRateHandlers.add(new TianJinBanRateHandler());
        bankRateHandlers.add(new ShenZhenNongShangBanRateHandler());
        bankRateHandlers.add(new ShangHaiBanRateHandler());
        bankRateHandlers.add(new NanJingBanRateHandler());
        bankRateHandlers.add(new SiChuanBanRateHandler());
        bankRateHandlers.add(new BaiXinBanRateHandler());
        bankRateHandlers.add(new WeiZhongBanRateHandler());
        bankRateHandlers.add(new GongShangBanRateHandler());
        bankRateHandlers.add(new JianSheBanRateHandler());
        bankRateHandlers.add(new ZhongguoBanRateHandler());
        bankRateHandlers.add(new JiaoTongBanRateHandler());
        bankRateHandlers.add(new NongYeBanRateHandler());
        bankRateHandlers.add(new ZhaoShangBanRateHandler());
        bankRateHandlers.add(new GuangDaBanRateHandler());
        bankRateHandlers.add(new PuFaBanRateHandler());
        bankRateHandlers.add(new ZhongXinBanRateHandler());
        bankRateHandlers.add(new XingYeBanRateHandler());
        bankRateHandlers.add(new HuaXiaBanRateHandler());
        bankRateHandlers.add(new GuangFaBanRateHandler());
        bankRateHandlers.add(new YouZhengBanRateHandler());
        bankRateHandlers.add(new WangShangBanRateHandler());
        bankRateHandlers.add(new ZhongBangBanRateHandler());
        bankRateHandlers.add(new HuNanSanXiangBanRateHandler());
        bankRateHandlers.add(new XiaMenBanRateHandler());
        bankRateHandlers.add(new TangShanBanRateHandler());
        bankRateHandlers.add(new NingBoBanRateHandler());
        bankRateHandlers.add(new LongJiangBanRateHandler());
        return bankRateHandlers;
    }
}
